package com.haierp.service.impl;

import java.util.List;

import org.eclipse.jetty.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.framework.service.impl.SuperServiceImpl;
import com.haierp.mapper.ShippingOrderMapper;
import com.haierp.mapper.ShippingTrackMapper;
import com.haierp.model.ShippingTrack;
import com.haierp.service.IShippingTrackService;
import com.haierp.util.ExpressUtil;
import com.haierp.util.JsonPageResult;

@Service("shippingTrackServic")
public class ShippingTrackServiceImpl extends SuperServiceImpl<ShippingTrackMapper, ShippingTrack>
		implements IShippingTrackService {

	@Autowired
	private ShippingTrackMapper shippingTrackMapper;

	@Autowired
	private ShippingOrderMapper shippingOrderMapper;

	@Override
	public JsonPageResult<List<ShippingTrack>> queryShippingTrack(String shippingNo) {
		JsonPageResult<List<ShippingTrack>> ShippingTrackResult = new JsonPageResult<>();
		List<ShippingTrack> shippingTrackList = shippingTrackMapper.queryShippingTrack(shippingNo);
		ShippingTrackResult.setData(shippingTrackList);
		return ShippingTrackResult;
	}

	@Override
	public void insertOrUpdateInfo() {
		/*List<ShippingTrack> shippingTrackList = shippingTrackMapper.queryStatus();

		shippingTrackList.forEach(shippingTrack -> {
			if (StringUtil.isNotBlank(shippingTrack.getInlandExpressId())
					&& StringUtil.isNotBlank(shippingTrack.getInlandExpressNo())
					&& !shippingTrack.getInlandExpressId().contains("haihu")) {
				String info = ExpressUtil.callbackLogisticsTrajectory(shippingTrack.getInlandExpressId(),
						shippingTrack.getInlandExpressNo());
				if (info.contains("签收")) {
					shippingOrderMapper.updateStatusByShippingNo(shippingTrack.getShippingNo());
				}
				shippingTrackMapper.updateInfo(info, shippingTrack.getShippingNo());
			}
		});*/
	}

}
